<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '推广渠道';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="channel-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('添加', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],
            'id',
            'created_at',
            'utm',
            [
                'attribute'=>'utm',
                'label' => '渠道链接',
                'format' => ['raw',],
                'content' => function($model){
                    return 'www.lonlife.mobi/?s='.$model->utm;
                }
            ],
            'note',
            //'updated_at',
            // 'created_by',
            // 'updated_by',

            [
                'class' => 'yii\grid\ActionColumn',
                'header' => '操作',
                'template' => '{view}{update}{delete}{qrcode}',
                'buttons' => [
                    'qrcode' => function ($url, $model, $key) {
                        return Html::a(' 下载二维码 ',
                            '/admin/channel/qrcode?utm='.$model->utm,
                            ['title' => '生成下载推广二维码', 'target' => '__black'] );
                    },
                ],
            ],
        ],
    ]); ?>
</div>